package com.nali.dal.expression;

import java.io.Serializable;
import java.util.LinkedList;
import java.util.List;


/**
 * CriteriaDto<br>&nbsp;
 * @author sam Created on 2011-1-20
 */
public class ExpressionDto<T extends Expression> implements Serializable {
	private static final long serialVersionUID = 4625593818897144563L;
	private List<ExpressionValue<T>> expressionValues=new LinkedList<ExpressionValue<T>>();
	private List<PropertyExpression<T>> propertyExpressions=new LinkedList<PropertyExpression<T>>();
	
	public ExpressionDto() {
		super();
	}
	
	public ExpressionDto(List<PropertyExpression<T>> propertyExpressions, List<ExpressionValue<T>> expressionValues) {
		super();
		this.expressionValues = expressionValues;
		this.propertyExpressions = propertyExpressions;
	}

	public ExpressionDto<T> add(PropertyExpression<T> pc) {
		propertyExpressions.add(pc);
		return this;
	}
	
	public ExpressionDto<T> add(ExpressionValue<T> expressionValue) {
		expressionValues.add(expressionValue);
		return this;
	}
	
	public ExpressionDto<T> add(String propertyName, T criteria) {
		propertyExpressions.add(new PropertyExpression<T>(propertyName, criteria));
		return this;
	}
	
	public ExpressionDto<T> add(String propertyName, T criteria, Serializable value) {
		expressionValues.add(new ExpressionValue<T>(propertyName, criteria, value));
		return this;
	}
	
	public ExpressionDto<T> add(String propertyName, T criteria, Serializable... value) {
		expressionValues.add(new ExpressionValue<T>(propertyName, criteria, value));
		return this;
	}

	public ExpressionDto<T> add(PropertyExpression<T> propertyExpression, Serializable value) {
		expressionValues.add(new ExpressionValue<T>(propertyExpression, value));
		return this;
	}

	public List<ExpressionValue<T>> getExpressionValues() {
		return expressionValues;
	}

	public List<PropertyExpression<T>> getPropertyExpressions() {
		return propertyExpressions;
	}

	public void setPropertyExpressions(List<PropertyExpression<T>> propertyExpressions) {
		this.propertyExpressions = propertyExpressions;
	}
}
